package com.netflexitysolutions.amazonws.ec2.internal.operations;

import com.amazonaws.ec2.doc._2009_04_04.PurchaseReservedInstancesOfferingType;
import com.netflexitysolutions.amazonws.ec2.EC2;

public class PurchaseReservedInstancesOfferingOperation extends
		SingleObjectOperationExecutor<PurchaseReservedInstancesOfferingType, String> {
	
	private Integer instanceCount;
	
	public PurchaseReservedInstancesOfferingOperation(EC2 ec2, String objectId, Integer instanceCount) {
		super(ec2, objectId);
		this.instanceCount = instanceCount;
	}

	@Override
	protected String call(PurchaseReservedInstancesOfferingType request) {
		if (instanceCount != null) {
			request.setInstanceCount(instanceCount.intValue());
		}
		request.setReservedInstancesOfferingId(objectId);
		return getEC2().getService().purchaseReservedInstancesOffering(request).getReservedInstancesId();
	}

}
